package com.sky.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfiguration {

    @Bean
    public Docket docket() {
        Docket docketBuild = new Docket(DocumentationType.SWAGGER_2).apiInfo(new ApiInfoBuilder()
                .description("苍穹外卖描述")
                .termsOfServiceUrl("http://localhost:8083")
                .contact("13171754463@163.com")
                .version("1.0")
                .build())
                .groupName("管理端接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.sky.controller.admin"))
                .paths(PathSelectors.any()).build();
        return docketBuild;
    }

    @Bean
    public Docket docketUser() {
        Docket docketBuild = new Docket(DocumentationType.SWAGGER_2).apiInfo(new ApiInfoBuilder()
                        .description("苍穹外卖描述")
                        .termsOfServiceUrl("http://localhost:8083")
                        .contact("13171754463@163.com")
                        .version("1.0")
                        .build())
                .groupName("用户端接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.sky.controller.user"))
                .paths(PathSelectors.any()).build();
        return docketBuild;
    }
}
